home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_300 / 331_01 / pcio.asm < prev    next >
Assembly Source File  |  1990-06-10  |  34KB  |  1,229 lines

  1. ; pcio
  2.  
  3. ; Most of these routines should not be called directly by the application.
  4. ; Routines are being added in term.c which relay the call to here.  In that
  5. ; way terminal specific functions will be consolidated in term.c.  By
  6. ; changing just term.c the program can be adapted to a different host,
  7. ; resulting in better portability.  Many of the routines contained here
  8. ; are unused, but may be useful for other applications.  Many of these
  9. ; functions could also be implemented mostly in C.  Some assembly language
  10. ; is essential for speed on slow systems, but it becomes less important
  11. ; on fast processors, and may eventually have to go away altogether for
  12. ; better portability.  The standard BIOS video calls are incredibly slow,
  13. ; and are mostly unused here.  On an 80386 system the screen refresh time
  14. ; is less than the keyboard autorepeat time with the interface in this
  15. ; file.
  16. ;
  17. ;                                 May 87 G. Osborn
  18.  
  19.  
  20.  
  21. ; Converted from DeSmet to the Microsoft version  3.0 macro
  22. ; assembler format.  Microsoft does not follow data labels
  23. ; by a colon.  Code segment labels are followed by a colon, though.
  24. ; Changed "byte" to "byte ptr" throughout.
  25.  
  26. ; Changed calling sequence to that of Microsoft C compiler version 3.0.
  27. ; Same as DeSmet except SI and DI must be saved in case register
  28. ; variables are used, so the new sequence is compatible with both compilers.
  29.  
  30. ; publics are defined two ways for compiler compatibility.  Each is
  31. ; defined as _LABEL (Microsoft) and LABEL_ (DeSmet).
  32.  
  33. ; Effort required to reconvert to DeSmet is minor
  34.  
  35. ;                                            2-18-87 G. Osborn
  36.  
  37.  
  38.  
  39. _TEXT SEGMENT  BYTE PUBLIC 'CODE'
  40. ; instructions
  41. _TEXT ENDS
  42.  
  43. CONST SEGMENT  WORD PUBLIC 'CONST'
  44. ; read only constants.  not constant strings.
  45. CONST ENDS
  46.  
  47. _BSS SEGMENT  WORD PUBLIC 'BSS'
  48. ; uninitialized static data
  49. _BSS ENDS
  50.  
  51. _DATA SEGMENT  WORD PUBLIC 'DATA'
  52. ; initialized global and static data
  53. _DATA ENDS
  54.  
  55. DGROUP GROUP CONST, _BSS, _DATA
  56.    ASSUME  CS: _TEXT, DS: DGROUP, SS: DGROUP, ES: DGROUP
  57.  
  58.  
  59.  
  60. ;------------------------------------------------------------------
  61. ; pcio.a  --  Screen and keyboard interface routines for the PC
  62. ;             Specific to DeSmet C
  63. ;
  64. ; last modified - 08/06/86
  65. ;
  66. ;
  67. ;                        !!! PLEASE NOTE !!!
  68. ;     This is not quite the same as pcio.a from DeSmet -
  69. ;     I've made some changes here and there for use with ged.
  70. ;     Am slowly changing all Desmet functions that use x,y co-ords
  71. ;     to work as col,row - but have not finished
  72. ;                                                    Mel Tearle
  73. ;------------------------------------------------------------------
  74.  
  75. ;------------------------------------------------------------------
  76. ;                         data starts here
  77. ;------------------------------------------------------------------
  78.  
  79. _DATA SEGMENT
  80.  
  81. ; In this implementation, all special and function keys are translated
  82. ; to the following values.
  83.  
  84. ; control key translations.  would be better done in C, because the
  85. ; convesion time is not critical.
  86.  
  87. up_char         equ   5    ;equ 196   mapped into cursor-pad
  88. down_char       equ  24    ;equ 197
  89. left_char       equ  19    ;equ 198
  90. right_char      equ   4    ;equ 199
  91. bol_char        equ  15    ;equ 200
  92. eol_char        equ  16    ;equ 201
  93. pageup_char     equ  18    ;equ 202
  94. pagedown_char   equ   3    ;equ 203
  95. Del_char        equ   7    ;equ 207
  96. Ins_char        equ  16h
  97.  
  98. ;  bof_char     equ 204      not used
  99. ;  eof_char     equ 205      not used
  100. ;  NextWord_char   equ 208   not used
  101. ;  PrevWord_char   equ 209   not used
  102.  
  103. M1      equ 210
  104. M2      equ 211
  105. M3      equ 212
  106. M4      equ 213
  107. M5      equ 214
  108. M6      equ 215
  109. M7      equ 216
  110. M8      equ 217
  111. M9      equ 218
  112. M10     equ 219
  113. M11     equ 220
  114. M12     equ 221
  115.  
  116. ; the table that is used to make the translation
  117. ; note - not all used
  118.  
  119. convert db  72, up_char
  120.         db  80, down_char
  121.         db  75, left_char
  122.         db  77, right_char
  123.         db  71, 220      ; <home> becomes beginning of file
  124.         db  79, 221      ; <end> becomes end of file
  125.         db  73, pageup_char
  126.         db  81, pagedown_char
  127.         db  113, 222    ; ^<up arrow> .. cursor to top of window
  128.         db  118, 223    ; cursor to bottom of window
  129.         db  82, Ins_char ; <ins> becomes ^V
  130.         db  83, Del_char
  131.         db  115, 15h      ; ^<left arrow> becomes ^U = cursor full left
  132.         db  116, 1Dh      ; ^<right arrow> becomes ^] = cursor full right
  133.         db  59, M1
  134.         db  60, M2
  135.         db  61, M3
  136.         db  62, M4
  137.         db  63, M5
  138.         db  64, M6
  139.         db  65, M7
  140.         db  66, M8
  141.         db  67, M9
  142.         db  68, M10
  143.         db  69, M11
  144.         db  70, M12
  145.         db   0, 255 ; illegal character
  146.  
  147.  
  148. ; equates for bios interface.
  149. ; the interrupt and codes for the screen interface interrupt.
  150.  
  151. video       equ 10h     ;interrupt for dealing with screen
  152.  
  153. mode        equ 0       ;code for setting new screen mode
  154. curtype     equ 1       ;code for setting new cursor type
  155. setcur      equ 2       ;code for addressing cursor
  156. readcur     equ 3       ;code for reading cursor location
  157. readlp      equ 4       ;code for reading light pen position
  158. setpage     equ 5       ;code to select active page
  159. scrollup    equ 6       ;code to scroll screen up
  160. scrolldn    equ 7       ;code to scroll screen nown
  161. readch      equ 8       ;code to read a character from screen
  162. writeach    equ 9       ;code to write char and attributes
  163. writech     equ 10      ;code to write character only
  164. setpal      equ 11      ;code to set new setpal or border
  165. wdot        equ 12      ;code to write a dot
  166. rdot        equ 13      ;code to read a dot
  167. wtty        equ 14      ;code to write as if teletype
  168. state       equ 15      ;code to find current screen status
  169.  
  170. ; int 10 (video) changes all registers except cs,ss,ds,es,bx,cx,dx
  171.  
  172. ; used in set_video
  173.  
  174. mono_adr     equ  0b000h   ;mono adapter
  175. graph_adr    equ  0b800h   ;graphics adapter*
  176.  
  177. vadrs        dw  0
  178.  
  179.  
  180. ; the interrupt and codes for the keyboard interface.
  181.  
  182. keyboard     equ 16h     ;interrupt 16 to deal with keyboard
  183.  
  184. cicode       equ 0       ;code for reading a character
  185. cstscode     equ 1       ;code for keyboard status
  186.  
  187.  
  188. ; caution: must change column number if 40 column mode
  189.  
  190. crt_cols    equ 80
  191.  
  192. ; variables available to a C88 program
  193.  
  194.         public  scr_cols_, scr_rows_, scr_scrollup_, scr_scrolldown_
  195.         public  scr_mode_, scr_page_, scr_attr_, scr_window_top_
  196.  
  197.         public  _scr_cols, _scr_rows, _scr_scrollup, _scr_scrolldown
  198.         public  _scr_mode, _scr_page, _scr_attr, _scr_window_top
  199.  
  200.  
  201. _scr_cols  label byte
  202. scr_cols_ db  crt_cols    ;current number of columns
  203.  
  204.  
  205. ; note- make 25 for ms-dos and 24 for cp/m as cp/m steals the bottom
  206. ; line.
  207.  
  208. scr_rows    equ  25
  209. _scr_rows   label byte
  210. scr_rows_   db  scr_rows     ;current number of rows, for ged, was 25
  211.  
  212. _scr_mode   label byte
  213. scr_mode_   db  0       ;current screen mode
  214.  
  215. _scr_page   label byte
  216. scr_page_   db  0       ;current page
  217.  
  218. _scr_attr   label byte
  219. scr_attr_   db  7       ;current attributes for screen
  220.                         ;7 is white letters on black
  221.  
  222. _scr_window_top label byte
  223. scr_window_top_ db  1   ;first line to scroll, was 0
  224.  
  225. ; variables needed by SEE. Not used here.
  226.  
  227. _scr_scrollup   label byte
  228. scr_scrollup_   db  0       ;zero if scrollup leaves top line alone
  229.  
  230. _scr_scrolldown label byte
  231. scr_scrolldown_ db  0       ;zero if scroll down supported
  232.  
  233. _DATA      ENDS
  234.  
  235. ;------------------------------------------------------------------
  236. ;                          code starts here
  237. ;------------------------------------------------------------------
  238.  
  239. _TEXT       SEGMENT
  240.             PUBLIC    _scr_setup
  241.  
  242. ;-------------------------------------------------------------------------
  243. ; SCR_SETUP_  scr_setup must be called before any use of any
  244. ;             other routine unless the starting mode is 80X25
  245. ;             character mode (3,4 or 7). Must be called for monochrome
  246. ;             (mode 7) for scr_cu